---
layout: "default"
title: "Int16"
description: "Swift documentation for 'Int16': A 16-bit signed integer value."
keywords: "Int16,struct,swift,documentation,addingReportingOverflow,advanced,distance,dividedReportingOverflow,dividingFullWidth,encode,hash,multipliedFullWidth,multipliedReportingOverflow,quotientAndRemainder,remainderReportingOverflow,signum,subtractingReportingOverflow,unsafeAdding,unsafeDivided,unsafeMultiplied,unsafeSubtracting,bitWidth,isSigned,max,min,bigEndian,byteSwapped,customMirror,customPlaygroundQuickLook,description,hashValue,leadingZeroBitCount,littleEndian,magnitude,nonzeroBitCount,trailingZeroBitCount,words,IntegerLiteralType,Magnitude"
root: "/v4.2"
---

<div class="intro-declaration"><code class="language-swift">struct Int16</code></div>

<div class="discussion comment">
    <p>A 16-bit signed integer value
type.</p>
</div>

<table class="standard">
<tr>
<th id="inheritance">Inheritance</th>
<td>
<code class="inherits">BinaryInteger, CVarArg, Codable, Comparable, CustomPlaygroundQuickLookable, CustomReflectable, CustomStringConvertible, Equatable, ExpressibleByIntegerLiteral, FixedWidthInteger, Hashable, LosslessStringConvertible, Numeric, SignedInteger, SignedNumeric, Strideable, _BitwiseOperations</code>
<span class="viz"><a href="hierarchy/">View Protocol Hierarchy &rarr;</a></span>
</td>
</tr>

<tr>
<th id="aliases">Associated Types</th>
<td>
<span id="aliasesmark"></span>
<div class="declaration">
<code class="language-swift">IntegerLiteralType = Int16</code>
<div class="comment">
    <p>A type that represents an integer literal.</p>
</div>
</div>
<div class="declaration">
<code class="language-swift">Magnitude = UInt16</code>
<div class="comment">
    <p>A type that can represent the absolute value of any possible value of
this type.</p>
</div>
</div>
</td>
</tr>

<tr>
<th>Nested Types</th>
<td><code class="nested">Int16.Words</code></td>
</tr>

<tr>
<th>Import</th>
<td><code class="language-swift">import Swift</code></td>
</tr>

</table>


<h3>Initializers</h3>
<div class="declaration inherited" id="init">
<a class="toggle-link" data-toggle="collapse" href="#comment-init">init()</a><div class="comment collapse" id="comment-init"><div class="p">
    <p>Creates a new value equal to zero.</p>

    <h4>Declaration</h4>    
    <code class="language-swift">init()</code>

        <h4>Declared In</h4>
            <a href="../../protocol/FixedWidthInteger/"><code>FixedWidthInteger</code></a>
        </div></div>
</div>
<div class="declaration" id="init_-double">
<a class="toggle-link" data-toggle="collapse" href="#comment-init_-double">init(<wbr>_: Double)</a><div class="comment collapse" id="comment-init_-double"><div class="p">
    <p>Creates an integer from the given floating-point value, rounding toward
zero.</p>

<p>Any fractional part of the value passed as <code>source</code> is removed, rounding
the value toward zero.</p>

<pre><code class="language-swift">let x = Int(21.5)
// x == 21
let y = Int(-21.5)
// y == -21</code></pre>

<p>If <code>source</code> is outside the bounds of this type after rounding toward
zero, a runtime error may occur.</p>

<pre><code class="language-swift">let z = UInt(-21.5)
// Error: ...the result would be less than UInt.min</code></pre>

<p><strong><code>source</code>:</strong>  A floating-point value to convert to an integer.
  <code>source</code> must be representable in this type after rounding toward
  zero.</p>

    <h4>Declaration</h4>    
    <code class="language-swift">init(_ source: Double)</code>

    </div></div>
</div>
<div class="declaration" id="init_-float">
<a class="toggle-link" data-toggle="collapse" href="#comment-init_-float">init(<wbr>_: Float)</a><div class="comment collapse" id="comment-init_-float"><div class="p">
    <p>Creates an integer from the given floating-point value, rounding toward
zero.</p>

<p>Any fractional part of the value passed as <code>source</code> is removed, rounding
the value toward zero.</p>

<pre><code class="language-swift">let x = Int(21.5)
// x == 21
let y = Int(-21.5)
// y == -21</code></pre>

<p>If <code>source</code> is outside the bounds of this type after rounding toward
zero, a runtime error may occur.</p>

<pre><code class="language-swift">let z = UInt(-21.5)
// Error: ...the result would be less than UInt.min</code></pre>

<p><strong><code>source</code>:</strong>  A floating-point value to convert to an integer.
  <code>source</code> must be representable in this type after rounding toward
  zero.</p>

    <h4>Declaration</h4>    
    <code class="language-swift">init(_ source: Float)</code>

    </div></div>
</div>
<div class="declaration" id="init_-float80">
<a class="toggle-link" data-toggle="collapse" href="#comment-init_-float80">init(<wbr>_: Float80)</a><div class="comment collapse" id="comment-init_-float80"><div class="p">
    <p>Creates an integer from the given floating-point value, rounding toward
zero.</p>

<p>Any fractional part of the value passed as <code>source</code> is removed, rounding
the value toward zero.</p>

<pre><code class="language-swift">let x = Int(21.5)
// x == 21
let y = Int(-21.5)
// y == -21</code></pre>

<p>If <code>source</code> is outside the bounds of this type after rounding toward
zero, a runtime error may occur.</p>

<pre><code class="language-swift">let z = UInt(-21.5)
// Error: ...the result would be less than UInt.min</code></pre>

<p><strong><code>source</code>:</strong>  A floating-point value to convert to an integer.
  <code>source</code> must be representable in this type after rounding toward
  zero.</p>

    <h4>Declaration</h4>    
    <code class="language-swift">init(_ source: Float80)</code>

    </div></div>
</div>
<div class="declaration inherited" id="init_">
<a class="toggle-link" data-toggle="collapse" href="#comment-init_">init(<wbr>_:)</a><div class="comment collapse" id="comment-init_"><div class="p">
    <p>Creates an integer from the given floating-point value, rounding toward
zero. Any fractional part of the value passed as <code>source</code> is removed.</p>

<pre><code class="language-swift">let x = Int(21.5)
// x == 21
let y = Int(-21.5)
// y == -21</code></pre>

<p>If <code>source</code> is outside the bounds of this type after rounding toward
zero, a runtime error may occur.</p>

<pre><code class="language-swift">let z = UInt(-21.5)
// Error: ...outside the representable range</code></pre>

<p><strong><code>source</code>:</strong>  A floating-point value to convert to an integer.
  <code>source</code> must be representable in this type after rounding toward
  zero.</p>

    <h4>Declaration</h4>    
    <code class="language-swift">init&lt;T&gt;(_ source: T)</code>

        <h4>Declared In</h4>
            <a href="../../protocol/FixedWidthInteger/"><code>FixedWidthInteger</code></a>
        ,    <a href="../../protocol/SignedInteger/"><code>SignedInteger</code></a>
        </div></div>
</div>
<div class="declaration inherited" id="init-bigendian_">
<a class="toggle-link" data-toggle="collapse" href="#comment-init-bigendian_">init(<wbr>bigEndian:)</a><div class="comment collapse" id="comment-init-bigendian_"><div class="p">
    <p>Creates an integer from its big-endian representation, changing the byte
order if necessary.</p>

<p><strong><code>value</code>:</strong>  A value to use as the big-endian representation of the
  new integer.</p>

    <h4>Declaration</h4>    
    <code class="language-swift">init(bigEndian value: Int16)</code>

        <h4>Declared In</h4>
            <a href="../../protocol/FixedWidthInteger/"><code>FixedWidthInteger</code></a>
        </div></div>
</div>
<div class="declaration" id="init-bitpattern_">
<a class="toggle-link" data-toggle="collapse" href="#comment-init-bitpattern_">init(<wbr>bitPattern:)</a><div class="comment collapse" id="comment-init-bitpattern_"><div class="p">
    <p>Creates a new instance with the same memory representation as the given
value.</p>

<p>This initializer does not perform any range or overflow checking. The
resulting instance may not have the same numeric value as
<code>bitPattern</code>---it is only guaranteed to use the same pattern of bits in
its binary representation.</p>

<p><strong><code>x</code>:</strong>  A value to use as the source of the new instance&#39;s binary
  representation.</p>

    <h4>Declaration</h4>    
    <code class="language-swift">init(bitPattern x: UInt16)</code>

    </div></div>
</div>
<div class="declaration inherited" id="init-clamping_">
<a class="toggle-link" data-toggle="collapse" href="#comment-init-clamping_">init(<wbr>clamping:)</a><div class="comment collapse" id="comment-init-clamping_"><div class="p">
    <p>Creates a new instance with the representable value that&#39;s closest to the
given integer.</p>

<p>If the value passed as <code>source</code> is greater than the maximum representable
value in this type, the result is the type&#39;s <code>max</code> value. If <code>source</code> is
less than the smallest representable value in this type, the result is
the type&#39;s <code>min</code> value.</p>

<p>In this example, <code>x</code> is initialized as an <code>Int8</code> instance by clamping
<code>500</code> to the range <code>-128...127</code>, and <code>y</code> is initialized as a <code>UInt</code>
instance by clamping <code>-500</code> to the range <code>0...UInt.max</code>.</p>

<pre><code class="language-swift">let x = Int8(clamping: 500)
// x == 127
// x == Int8.max

let y = UInt(clamping: -500)
// y == 0</code></pre>

<p><strong><code>source</code>:</strong>  An integer to convert to this type.</p>

    <h4>Declaration</h4>    
    <code class="language-swift">init&lt;Other&gt;(clamping source: Other)</code>

        <h4>Declared In</h4>
            <a href="../../protocol/FixedWidthInteger/"><code>FixedWidthInteger</code></a>
        </div></div>
</div>
<div class="declaration" id="init-from_">
<a class="toggle-link" data-toggle="collapse" href="#comment-init-from_">init(<wbr>from:)</a><div class="comment collapse" id="comment-init-from_"><div class="p">
    <p>Creates a new instance by decoding from the given decoder.</p>

<p>This initializer throws an error if reading from the decoder fails, or
if the data read is corrupted or otherwise invalid.</p>

<p><strong><code>decoder</code>:</strong>  The decoder to read data from.</p>

    <h4>Declaration</h4>    
    <code class="language-swift">init(from decoder: Decoder)</code>

    </div></div>
</div>
<div class="declaration inherited" id="init-integerliteral_">
<a class="toggle-link" data-toggle="collapse" href="#comment-init-integerliteral_">init(<wbr>integerLiteral:)</a><div class="comment collapse" id="comment-init-integerliteral_"><div class="p">
    <p>Creates an instance initialized to the specified integer value.</p>

<p>Do not call this initializer directly. Instead, initialize a variable or
constant using an integer literal. For example:</p>

<pre><code class="language-swift">let x = 23</code></pre>

<p>In this example, the assignment to the <code>x</code> constant calls this integer
literal initializer behind the scenes.</p>

<p><strong><code>value</code>:</strong>  The value to create.</p>

    <h4>Declaration</h4>    
    <code class="language-swift">init(integerLiteral value: Int16)</code>

        <h4>Declared In</h4>
            <a href="../../protocol/FixedWidthInteger/"><code>FixedWidthInteger</code></a>
        </div></div>
</div>
<div class="declaration inherited" id="init-littleendian_">
<a class="toggle-link" data-toggle="collapse" href="#comment-init-littleendian_">init(<wbr>littleEndian:)</a><div class="comment collapse" id="comment-init-littleendian_"><div class="p">
    <p>Creates an integer from its little-endian representation, changing the
byte order if necessary.</p>

<p><strong><code>value</code>:</strong>  A value to use as the little-endian representation of
  the new integer.</p>

    <h4>Declaration</h4>    
    <code class="language-swift">init(littleEndian value: Int16)</code>

        <h4>Declared In</h4>
            <a href="../../protocol/FixedWidthInteger/"><code>FixedWidthInteger</code></a>
        </div></div>
</div>
<div class="declaration inherited" id="init-truncatingifneeded_">
<a class="toggle-link" data-toggle="collapse" href="#comment-init-truncatingifneeded_">init(<wbr>truncatingIfNeeded:)</a><div class="comment collapse" id="comment-init-truncatingifneeded_"><div class="p">
    <p>Creates a new instance from the bit pattern of the given instance by
truncating or sign-extending if needed to fit this type.</p>

<p>When the bit width of <code>T</code> (the type of <code>source</code>) is equal to or greater
than this type&#39;s bit width, the result is the truncated
least-significant bits of <code>source</code>. For example, when converting a
16-bit value to an 8-bit type, only the lower 8 bits of <code>source</code> are
used.</p>

<pre><code class="language-swift">let p: Int16 = -500
// &#39;p&#39; has a binary representation of 11111110_00001100
let q = Int8(truncatingIfNeeded: p)
// q == 12
// &#39;q&#39; has a binary representation of 00001100</code></pre>

<p>When the bit width of <code>T</code> is less than this type&#39;s bit width, the result
is <em>sign-extended</em> to fill the remaining bits. That is, if <code>source</code> is
negative, the result is padded with ones; otherwise, the result is
padded with zeros.</p>

<pre><code class="language-swift">let u: Int8 = 21
// &#39;u&#39; has a binary representation of 00010101
let v = Int16(truncatingIfNeeded: u)
// v == 21
// &#39;v&#39; has a binary representation of 00000000_00010101

let w: Int8 = -21
// &#39;w&#39; has a binary representation of 11101011
let x = Int16(truncatingIfNeeded: w)
// x == -21
// &#39;x&#39; has a binary representation of 11111111_11101011
let y = UInt16(truncatingIfNeeded: w)
// y == 65515
// &#39;y&#39; has a binary representation of 11111111_11101011</code></pre>

<p><strong><code>source</code>:</strong>  An integer to convert to this type.</p>

    <h4>Declaration</h4>    
    <code class="language-swift">init&lt;T&gt;(truncatingIfNeeded source: T)</code>

        <h4>Declared In</h4>
            <a href="../../protocol/FixedWidthInteger/"><code>FixedWidthInteger</code></a>
        </div></div>
</div>
<div class="declaration inherited" id="init_radix_">
<a class="toggle-link" data-toggle="collapse" href="#comment-init_radix_">init?(<wbr>_:<wbr>radix:)</a><div class="comment collapse" id="comment-init_radix_"><div class="p">
    <p>Creates a new integer value from the given string and radix.</p>

<p>The string passed as <code>text</code> may begin with a plus or minus sign character
(<code>+</code> or <code>-</code>), followed by one or more numeric digits (<code>0-9</code>) or letters
(<code>a-z</code> or <code>A-Z</code>). Parsing of the string is case insensitive.</p>

<pre><code class="language-swift">let x = Int(&quot;123&quot;)
// x == 123

let y = Int(&quot;-123&quot;, radix: 8)
// y == -83
let y = Int(&quot;+123&quot;, radix: 8)
// y == +83

let z = Int(&quot;07b&quot;, radix: 16)
// z == 123</code></pre>

<p>If <code>text</code> is in an invalid format or contains characters that are out of
bounds for the given <code>radix</code>, or if the value it denotes in the given
<code>radix</code> is not representable, the result is <code>nil</code>. For example, the
following conversions result in <code>nil</code>:</p>

<pre><code class="language-swift">Int(&quot; 100&quot;)                       // Includes whitespace
Int(&quot;21-50&quot;)                      // Invalid format
Int(&quot;ff6600&quot;)                     // Characters out of bounds
Int(&quot;zzzzzzzzzzzzz&quot;, radix: 36)   // Out of range</code></pre>

<p><strong>Parameters:</strong>
  <strong>text:</strong> The ASCII representation of a number in the radix passed as
    <code>radix</code>.
  <strong>radix:</strong> The radix, or base, to use for converting <code>text</code> to an integer
    value. <code>radix</code> must be in the range <code>2...36</code>. The default is 10.</p>

    <h4>Declaration</h4>    
    <code class="language-swift">init?&lt;S&gt;(_ text: S, radix: Int = default)</code>

        <h4>Declared In</h4>
            <a href="../../protocol/FixedWidthInteger/"><code>FixedWidthInteger</code></a>
        </div></div>
</div>
<div class="declaration" id="init-exactly_-double">
<a class="toggle-link" data-toggle="collapse" href="#comment-init-exactly_-double">init?(<wbr>exactly: Double)</a><div class="comment collapse" id="comment-init-exactly_-double"><div class="p">
    <p>Creates an integer from the given floating-point value, if it can be
represented exactly.</p>

<p>If the value passed as <code>source</code> is not representable exactly, the result
is <code>nil</code>. In the following example, the constant <code>x</code> is successfully
created from a value of <code>21.0</code>, while the attempt to initialize the
constant <code>y</code> from <code>21.5</code> fails:</p>

<pre><code class="language-swift">let x = Int(exactly: 21.0)
// x == Optional(21)
let y = Int(exactly: 21.5)
// y == nil</code></pre>

<p><strong><code>source</code>:</strong>  A floating-point value to convert to an integer.</p>

    <h4>Declaration</h4>    
    <code class="language-swift">init?(exactly source: Double)</code>

    </div></div>
</div>
<div class="declaration" id="init-exactly_-float">
<a class="toggle-link" data-toggle="collapse" href="#comment-init-exactly_-float">init?(<wbr>exactly: Float)</a><div class="comment collapse" id="comment-init-exactly_-float"><div class="p">
    <p>Creates an integer from the given floating-point value, if it can be
represented exactly.</p>

<p>If the value passed as <code>source</code> is not representable exactly, the result
is <code>nil</code>. In the following example, the constant <code>x</code> is successfully
created from a value of <code>21.0</code>, while the attempt to initialize the
constant <code>y</code> from <code>21.5</code> fails:</p>

<pre><code class="language-swift">let x = Int(exactly: 21.0)
// x == Optional(21)
let y = Int(exactly: 21.5)
// y == nil</code></pre>

<p><strong><code>source</code>:</strong>  A floating-point value to convert to an integer.</p>

    <h4>Declaration</h4>    
    <code class="language-swift">init?(exactly source: Float)</code>

    </div></div>
</div>
<div class="declaration" id="init-exactly_-float80">
<a class="toggle-link" data-toggle="collapse" href="#comment-init-exactly_-float80">init?(<wbr>exactly: Float80)</a><div class="comment collapse" id="comment-init-exactly_-float80"><div class="p">
    <p>Creates an integer from the given floating-point value, if it can be
represented exactly.</p>

<p>If the value passed as <code>source</code> is not representable exactly, the result
is <code>nil</code>. In the following example, the constant <code>x</code> is successfully
created from a value of <code>21.0</code>, while the attempt to initialize the
constant <code>y</code> from <code>21.5</code> fails:</p>

<pre><code class="language-swift">let x = Int(exactly: 21.0)
// x == Optional(21)
let y = Int(exactly: 21.5)
// y == nil</code></pre>

<p><strong><code>source</code>:</strong>  A floating-point value to convert to an integer.</p>

    <h4>Declaration</h4>    
    <code class="language-swift">init?(exactly source: Float80)</code>

    </div></div>
</div>
<div class="declaration inherited" id="init-exactly_">
<a class="toggle-link" data-toggle="collapse" href="#comment-init-exactly_">init?(<wbr>exactly:)</a><div class="comment collapse" id="comment-init-exactly_"><div class="p">
    <p>Creates an integer from the given floating-point value, if it can be
represented exactly.</p>

<p>If the value passed as <code>source</code> is not representable exactly, the result
is <code>nil</code>. In the following example, the constant <code>x</code> is successfully
created from a value of <code>21.0</code>, while the attempt to initialize the
constant <code>y</code> from <code>21.5</code> fails:</p>

<pre><code class="language-swift">let x = Int(exactly: 21.0)
// x == Optional(21)
let y = Int(exactly: 21.5)
// y == nil</code></pre>

<p><strong><code>source</code>:</strong>  A floating-point value to convert to an integer.</p>

    <h4>Declaration</h4>    
    <code class="language-swift">init?&lt;T&gt;(exactly source: T)</code>

        <h4>Declared In</h4>
            <a href="../../protocol/FixedWidthInteger/"><code>FixedWidthInteger</code></a>
        ,    <a href="../../protocol/SignedInteger/"><code>SignedInteger</code></a>
        </div></div>
</div>

<h3>Static Variables</h3>
<div class="declaration" id="static-var-bitwidth_-int">
<a class="toggle-link" data-toggle="collapse" href="#comment-static-var-bitwidth_-int">static var bitWidth: Int</a><div class="comment collapse" id="comment-static-var-bitwidth_-int"><div class="p">
    <p>The number of bits used for the underlying binary representation of
values of this type.</p>

<p>The bit width of a <code>Int16</code> instance is 16.</p>

    <h4>Declaration</h4>    
    <code class="language-swift">static var bitWidth: Int { get }</code>

    </div></div>
</div>
<div class="declaration inherited" id="static-var-issigned_-bool">
<a class="toggle-link" data-toggle="collapse" href="#comment-static-var-issigned_-bool">static var isSigned: Bool</a><div class="comment collapse" id="comment-static-var-issigned_-bool"><div class="p">
    <p>A Boolean value indicating whether this type is a signed integer type.</p>

<p>This property is always <code>true</code> for signed integer types.</p>

    <h4>Declaration</h4>    
    <code class="language-swift">static var isSigned: Bool { get }</code>

        <h4>Declared In</h4>
            <a href="../../protocol/SignedInteger/"><code>SignedInteger</code></a>
        </div></div>
</div>
<div class="declaration inherited" id="static-var-max_-self">
<a class="toggle-link" data-toggle="collapse" href="#comment-static-var-max_-self">static var max: Int16</a><div class="comment collapse" id="comment-static-var-max_-self"><div class="p">
    <p>The maximum representable integer in this type.</p>

<p>For signed integer types, this value is <code>(2 ** (bitWidth - 1)) - 1</code>,
where <code>**</code> is exponentiation.</p>

    <h4>Declaration</h4>    
    <code class="language-swift">static var max: Int16 { get }</code>

        <h4>Declared In</h4>
            <a href="../../protocol/SignedInteger/"><code>SignedInteger</code></a>
        </div></div>
</div>
<div class="declaration inherited" id="static-var-min_-self">
<a class="toggle-link" data-toggle="collapse" href="#comment-static-var-min_-self">static var min: Int16</a><div class="comment collapse" id="comment-static-var-min_-self"><div class="p">
    <p>The minimum representable integer in this type.</p>

<p>For signed integer types, this value is <code>-(2 ** (bitWidth - 1))</code>, where
<code>**</code> is exponentiation.</p>

    <h4>Declaration</h4>    
    <code class="language-swift">static var min: Int16 { get }</code>

        <h4>Declared In</h4>
            <a href="../../protocol/SignedInteger/"><code>SignedInteger</code></a>
        </div></div>
</div>

<h3>Instance Variables</h3>
<div class="declaration inherited" id="var-bigendian_-self">
<a class="toggle-link" data-toggle="collapse" href="#comment-var-bigendian_-self">var bigEndian: Int16</a><div class="comment collapse" id="comment-var-bigendian_-self"><div class="p">
    <p>The big-endian representation of this integer.</p>

<p>If necessary, the byte order of this value is reversed from the typical
byte order of this integer type. On a big-endian platform, for any
integer <code>x</code>, <code>x == x.bigEndian</code>.</p>

    <h4>Declaration</h4>    
    <code class="language-swift">var bigEndian: Int16 { get }</code>

        <h4>Declared In</h4>
            <a href="../../protocol/FixedWidthInteger/"><code>FixedWidthInteger</code></a>
        </div></div>
</div>
<div class="declaration" id="var-byteswapped_-int16">
<a class="toggle-link" data-toggle="collapse" href="#comment-var-byteswapped_-int16">var byteSwapped: Int16</a><div class="comment collapse" id="comment-var-byteswapped_-int16"><div class="p">
    <p>A representation of this integer with the byte order swapped.</p>

    <h4>Declaration</h4>    
    <code class="language-swift">var byteSwapped: Int16 { get }</code>

    </div></div>
</div>
<div class="declaration" id="var-custommirror_-mirror">
<a class="toggle-link" data-toggle="collapse" href="#comment-var-custommirror_-mirror">var customMirror: Mirror</a><div class="comment collapse" id="comment-var-custommirror_-mirror"><div class="p">
    <p>A mirror that reflects the <code>Int16</code> instance.</p>

    <h4>Declaration</h4>    
    <code class="language-swift">var customMirror: Mirror { get }</code>

    </div></div>
</div>
<div class="declaration" id="var-customplaygroundquicklook_-playgroundquicklook">
<a class="toggle-link" data-toggle="collapse" href="#comment-var-customplaygroundquicklook_-playgroundquicklook">var customPlaygroundQuickLook: PlaygroundQuickLook</a><div class="comment collapse" id="comment-var-customplaygroundquicklook_-playgroundquicklook"><div class="p">
    <p>A custom playground Quick Look for the <code>Int16</code> instance.</p>

<p><em>Deprecated:</em> Int16.customPlaygroundQuickLook will be removed in a future Swift version.</p>

    <h4>Declaration</h4>    
    <code class="language-swift">var customPlaygroundQuickLook: PlaygroundQuickLook { get }</code>

    </div></div>
</div>
<div class="declaration inherited" id="var-description_-string">
<a class="toggle-link" data-toggle="collapse" href="#comment-var-description_-string">var description: String</a><div class="comment collapse" id="comment-var-description_-string"><div class="p">
    <p>A textual representation of this value.</p>

    <h4>Declaration</h4>    
    <code class="language-swift">var description: String { get }</code>

        <h4>Declared In</h4>
            <a href="../../protocol/FixedWidthInteger/"><code>FixedWidthInteger</code></a>
        </div></div>
</div>
<div class="declaration" id="var-hashvalue_-int">
<a class="toggle-link" data-toggle="collapse" href="#comment-var-hashvalue_-int">var hashValue: Int</a><div class="comment collapse" id="comment-var-hashvalue_-int"><div class="p">
    <p>The integer&#39;s hash value.</p>

<p>The hash value is not guaranteed to be stable across different
invocations of the same program. Do not persist the hash value across
program runs.</p>

    <h4>Declaration</h4>    
    <code class="language-swift">var hashValue: Int { get }</code>

    </div></div>
</div>
<div class="declaration" id="var-leadingzerobitcount_-int">
<a class="toggle-link" data-toggle="collapse" href="#comment-var-leadingzerobitcount_-int">var leadingZeroBitCount: Int</a><div class="comment collapse" id="comment-var-leadingzerobitcount_-int"><div class="p">
    <p>The number of leading zeros in this value&#39;s binary representation.</p>

<p>For example, in an integer type with a <code>bitWidth</code> value of 8,
the number <em>31</em> has three leading zeros.</p>

<pre><code class="language-swift">let x: Int8 = 0b0001_1111
// x == 31
// x.leadingZeroBitCount == 3</code></pre>

    <h4>Declaration</h4>    
    <code class="language-swift">var leadingZeroBitCount: Int { get }</code>

    </div></div>
</div>
<div class="declaration inherited" id="var-littleendian_-self">
<a class="toggle-link" data-toggle="collapse" href="#comment-var-littleendian_-self">var littleEndian: Int16</a><div class="comment collapse" id="comment-var-littleendian_-self"><div class="p">
    <p>The little-endian representation of this integer.</p>

<p>If necessary, the byte order of this value is reversed from the typical
byte order of this integer type. On a little-endian platform, for any
integer <code>x</code>, <code>x == x.littleEndian</code>.</p>

    <h4>Declaration</h4>    
    <code class="language-swift">var littleEndian: Int16 { get }</code>

        <h4>Declared In</h4>
            <a href="../../protocol/FixedWidthInteger/"><code>FixedWidthInteger</code></a>
        </div></div>
</div>
<div class="declaration" id="var-magnitude_-uint16">
<a class="toggle-link" data-toggle="collapse" href="#comment-var-magnitude_-uint16">var magnitude: UInt16</a><div class="comment collapse" id="comment-var-magnitude_-uint16"><div class="p">
    <p>The magnitude of this value.</p>

<p>For any numeric value <code>x</code>, <code>x.magnitude</code> is the absolute value of <code>x</code>.
You can use the <code>magnitude</code> property in operations that are simpler to
implement in terms of unsigned values, such as printing the value of an
integer, which is just printing a &#39;-&#39; character in front of an absolute
value.</p>

<pre><code class="language-swift">let x = -200
// x.magnitude == 200</code></pre>

<p>The global <code>abs(_:)</code> function provides more familiar syntax when you need
to find an absolute value. In addition, because <code>abs(_:)</code> always returns
a value of the same type, even in a generic context, using the function
instead of the <code>magnitude</code> property is encouraged.</p>

    <h4>Declaration</h4>    
    <code class="language-swift">var magnitude: UInt16 { get }</code>

    </div></div>
</div>
<div class="declaration" id="var-nonzerobitcount_-int">
<a class="toggle-link" data-toggle="collapse" href="#comment-var-nonzerobitcount_-int">var nonzeroBitCount: Int</a><div class="comment collapse" id="comment-var-nonzerobitcount_-int"><div class="p">
    <p>The number of bits equal to 1 in this value&#39;s binary representation.</p>

<p>For example, in a fixed-width integer type with a <code>bitWidth</code> value of 8,
the number <em>31</em> has five bits equal to <em>1</em>.</p>

<pre><code class="language-swift">let x: Int8 = 0b0001_1111
// x == 31
// x.nonzeroBitCount == 5</code></pre>

    <h4>Declaration</h4>    
    <code class="language-swift">var nonzeroBitCount: Int { get }</code>

    </div></div>
</div>
<div class="declaration" id="var-trailingzerobitcount_-int">
<a class="toggle-link" data-toggle="collapse" href="#comment-var-trailingzerobitcount_-int">var trailingZeroBitCount: Int</a><div class="comment collapse" id="comment-var-trailingzerobitcount_-int"><div class="p">
    <p>The number of trailing zeros in this value&#39;s binary representation.</p>

<p>For example, the number <em>-8</em> has three trailing zeros.</p>

<pre><code class="language-swift">let x = Int8(bitPattern: 0b1111_1000)
// x == -8
// x.trailingZeroBitCount == 3</code></pre>

    <h4>Declaration</h4>    
    <code class="language-swift">var trailingZeroBitCount: Int { get }</code>

    </div></div>
</div>
<div class="declaration" id="var-words_-int16-words">
<a class="toggle-link" data-toggle="collapse" href="#comment-var-words_-int16-words">var words: Int16.Words</a><div class="comment collapse" id="comment-var-words_-int16-words"><div class="p">
    <p>A collection containing the words of this value&#39;s binary
representation, in order from the least significant to most significant.</p>

<p>Negative values are returned in two&#39;s complement representation,
regardless of the type&#39;s underlying implementation.</p>

    <h4>Declaration</h4>    
    <code class="language-swift">var words: Int16.Words { get }</code>

    </div></div>
</div>



<h3>Instance Methods</h3>
<div class="declaration" id="func-addingreportingoverflow_">
<a class="toggle-link" data-toggle="collapse" href="#comment-func-addingreportingoverflow_">func addingReportingOverflow(<wbr>_:)</a>
        
<div class="comment collapse" id="comment-func-addingreportingoverflow_"><div class="p">
    <p>Returns the sum of this value and the given value, along with a Boolean
value indicating whether overflow occurred in the operation.</p>

<p><strong><code>rhs</code>:</strong>  The value to add to this value.
<strong>Returns:</strong> A tuple containing the result of the addition along with a
  Boolean value indicating whether overflow occurred. If the <code>overflow</code>
  component is <code>false</code>, the <code>partialValue</code> component contains the entire
  sum. If the <code>overflow</code> component is <code>true</code>, an overflow occurred and
  the <code>partialValue</code> component contains the truncated sum of this value
  and <code>rhs</code>.</p>

    <h4>Declaration</h4>    
    <code class="language-swift">func addingReportingOverflow(_ other: Int16) -&gt; (partialValue: Int16, overflow: Bool)</code>
    
    
</div></div>
</div>
<div class="declaration inherited" id="func-advanced-by_">
<a class="toggle-link" data-toggle="collapse" href="#comment-func-advanced-by_">func advanced(<wbr>by:)</a>
        
<div class="comment collapse" id="comment-func-advanced-by_"><div class="p">
    <p>Returns a value that is offset the specified distance from this value.</p>

<p>Use the <code>advanced(by:)</code> method in generic code to offset a value by a
specified distance. If you&#39;re working directly with numeric values, use
the addition operator (<code>+</code>) instead of this method.</p>

<p>For a value <code>x</code>, a distance <code>n</code>, and a value <code>y = x.advanced(by: n)</code>,
<code>x.distance(to: y) == n</code>.</p>

<p><strong><code>n</code>:</strong>  The distance to advance this value.
<strong>Returns:</strong> A value that is offset from this value by <code>n</code>.</p>

    <h4>Declaration</h4>    
    <code class="language-swift">func advanced(by n: Int) -&gt; Int16</code>
    
        <h4>Declared In</h4>
        <a href="../../protocol/FixedWidthInteger/"><code>FixedWidthInteger</code></a>    
</div></div>
</div>
<div class="declaration inherited" id="func-distance-to_">
<a class="toggle-link" data-toggle="collapse" href="#comment-func-distance-to_">func distance(<wbr>to:)</a>
        
<div class="comment collapse" id="comment-func-distance-to_"><div class="p">
    <p>Returns the distance from this value to the given value, expressed as a
stride.</p>

<p>For two values <code>x</code> and <code>y</code>, and a distance <code>n = x.distance(to: y)</code>,
<code>x.advanced(by: n) == y</code>.</p>

<p><strong><code>other</code>:</strong>  The value to calculate the distance to.
<strong>Returns:</strong> The distance from this value to <code>other</code>.</p>

    <h4>Declaration</h4>    
    <code class="language-swift">func distance(to other: Int16) -&gt; Int</code>
    
        <h4>Declared In</h4>
        <a href="../../protocol/FixedWidthInteger/"><code>FixedWidthInteger</code></a>    
</div></div>
</div>
<div class="declaration" id="func-dividedreportingoverflow-by_">
<a class="toggle-link" data-toggle="collapse" href="#comment-func-dividedreportingoverflow-by_">func dividedReportingOverflow(<wbr>by:)</a>
        
<div class="comment collapse" id="comment-func-dividedreportingoverflow-by_"><div class="p">
    <p>Returns the quotient obtained by dividing this value by the given value,
along with a Boolean value indicating whether overflow occurred in the
operation.</p>

<p>Dividing by zero is not an error when using this method. For a value <code>x</code>,
the result of <code>x.dividedReportingOverflow(by: 0)</code> is <code>(x, true)</code>.</p>

<p><strong><code>rhs</code>:</strong>  The value to divide this value by.
<strong>Returns:</strong> A tuple containing the result of the division along with a
  Boolean value indicating whether overflow occurred. If the <code>overflow</code>
  component is <code>false</code>, the <code>partialValue</code> component contains the entire
  quotient. If the <code>overflow</code> component is <code>true</code>, an overflow occurred
  and the <code>partialValue</code> component contains either the truncated quotient
  or, if the quotient is undefined, the dividend.</p>

    <h4>Declaration</h4>    
    <code class="language-swift">func dividedReportingOverflow(by other: Int16) -&gt; (partialValue: Int16, overflow: Bool)</code>
    
    
</div></div>
</div>
<div class="declaration" id="func-dividingfullwidth-dividend_-high_-int16_">
<a class="toggle-link" data-toggle="collapse" href="#comment-func-dividingfullwidth-dividend_-high_-int16_">func dividingFullWidth(<wbr>_ dividend: (<wbr>high:<wbr> Int16,:)</a>
        
<div class="comment collapse" id="comment-func-dividingfullwidth-dividend_-high_-int16_"><div class="p">
    <p>Returns a tuple containing the quotient and remainder of dividing the
given value by this value.</p>

<p>The resulting quotient must be representable within the bounds of the
type. If the quotient of dividing <code>dividend</code> by this value is too large
to represent in the type, a runtime error may occur.</p>

<p><strong><code>dividend</code>:</strong>  A tuple containing the high and low parts of a
  double-width integer. The <code>high</code> component of the value carries the
  sign, if the type is signed.
<strong>Returns:</strong> A tuple containing the quotient and remainder of <code>dividend</code>
  divided by this value.</p>

    <h4>Declaration</h4>    
    <code class="language-swift">func dividingFullWidth(_ dividend: (high: Int16, low: Int16.Magnitude)) -&gt; (quotient: Int16, remainder: Int16)</code>
    
    
</div></div>
</div>
<div class="declaration" id="func-encode-to_">
<a class="toggle-link" data-toggle="collapse" href="#comment-func-encode-to_">func encode(<wbr>to:)</a>
        
<div class="comment collapse" id="comment-func-encode-to_"><div class="p">
    <p>Encodes this value into the given encoder.</p>

<p>This function throws an error if any values are invalid for the given
encoder&#39;s format.</p>

<p><strong><code>encoder</code>:</strong>  The encoder to write data to.</p>

    <h4>Declaration</h4>    
    <code class="language-swift">func encode(to encoder: Encoder) throws</code>
    
    
</div></div>
</div>
<div class="declaration" id="func-hash-into_">
<a class="toggle-link" data-toggle="collapse" href="#comment-func-hash-into_">func hash(<wbr>into:)</a>
        
<div class="comment collapse" id="comment-func-hash-into_"><div class="p">
    <p>Hashes the essential components of this value by feeding them into the
given hasher.</p>

<p><strong><code>hasher</code>:</strong>  The hasher to use when combining the components
  of this instance.</p>

    <h4>Declaration</h4>    
    <code class="language-swift">func hash(into hasher: inout Hasher)</code>
    
    
</div></div>
</div>
<div class="declaration" id="func-multipliedfullwidth-by_">
<a class="toggle-link" data-toggle="collapse" href="#comment-func-multipliedfullwidth-by_">func multipliedFullWidth(<wbr>by:)</a>
        
<div class="comment collapse" id="comment-func-multipliedfullwidth-by_"><div class="p">
    <p>Returns a tuple containing the high and low parts of the result of
multiplying this value by the given value.</p>

<p>Use this method to calculate the full result of a product that would
otherwise overflow. Unlike traditional truncating multiplication, the
<code>multipliedFullWidth(by:)</code> method returns a tuple
containing both the <code>high</code> and <code>low</code> parts of the product of this value and
<code>other</code>. The following example uses this method to multiply two <code>UInt8</code>
values that normally overflow when multiplied:</p>

<pre><code class="language-swift">let x: UInt8 = 100
let y: UInt8 = 20
let result = x.multipliedFullWidth(by: y)
// result.high == 0b00000111
// result.low  == 0b11010000</code></pre>

<p>The product of <code>x</code> and <code>y</code> is 2000, which is too large to represent in a
<code>UInt8</code> instance. The <code>high</code> and <code>low</code> properties of the <code>result</code> value
represent 2000 when concatenated to form a double-width integer; that
is, using <code>result.high</code> as the high byte and <code>result.low</code> as the low byte
of a <code>UInt16</code> instance.</p>

<pre><code class="language-swift">let z = UInt16(result.high) &lt;&lt; 8 | UInt16(result.low)
// z == 2000</code></pre>

<p><strong><code>other</code>:</strong>  The value to multiply this value by.
<strong>Returns:</strong> A tuple containing the high and low parts of the result of
  multiplying this value and <code>other</code>.</p>

    <h4>Declaration</h4>    
    <code class="language-swift">func multipliedFullWidth(by other: Int16) -&gt; (high: Int16, low: Int16.Magnitude)</code>
    
    
</div></div>
</div>
<div class="declaration" id="func-multipliedreportingoverflow-by_">
<a class="toggle-link" data-toggle="collapse" href="#comment-func-multipliedreportingoverflow-by_">func multipliedReportingOverflow(<wbr>by:)</a>
        
<div class="comment collapse" id="comment-func-multipliedreportingoverflow-by_"><div class="p">
    <p>Returns the product of this value and the given value, along with a
Boolean value indicating whether overflow occurred in the operation.</p>

<p><strong><code>rhs</code>:</strong>  The value to multiply by this value.
<strong>Returns:</strong> A tuple containing the result of the multiplication along with
  a Boolean value indicating whether overflow occurred. If the <code>overflow</code>
  component is <code>false</code>, the <code>partialValue</code> component contains the entire
  product. If the <code>overflow</code> component is <code>true</code>, an overflow occurred and
  the <code>partialValue</code> component contains the truncated product of this
  value and <code>rhs</code>.</p>

    <h4>Declaration</h4>    
    <code class="language-swift">func multipliedReportingOverflow(by other: Int16) -&gt; (partialValue: Int16, overflow: Bool)</code>
    
    
</div></div>
</div>
<div class="declaration inherited" id="func-quotientandremainder-dividingby_">
<a class="toggle-link" data-toggle="collapse" href="#comment-func-quotientandremainder-dividingby_">func quotientAndRemainder(<wbr>dividingBy:)</a>
        
<div class="comment collapse" id="comment-func-quotientandremainder-dividingby_"><div class="p">
    <p>Returns the quotient and remainder of this value divided by the given
value.</p>

<p>Use this method to calculate the quotient and remainder of a division at
the same time.</p>

<pre><code class="language-swift">let x = 1_000_000
let (q, r) = x.quotientAndRemainder(dividingBy: 933)
// q == 1071
// r == 757</code></pre>

<p><strong><code>rhs</code>:</strong>  The value to divide this value by.
<strong>Returns:</strong> A tuple containing the quotient and remainder of this value
  divided by <code>rhs</code>.</p>

    <h4>Declaration</h4>    
    <code class="language-swift">func quotientAndRemainder(dividingBy rhs: Int16) -&gt; (quotient: Int16, remainder: Int16)</code>
    
        <h4>Declared In</h4>
        <a href="../../protocol/FixedWidthInteger/"><code>FixedWidthInteger</code></a>    
</div></div>
</div>
<div class="declaration" id="func-remainderreportingoverflow-dividingby_">
<a class="toggle-link" data-toggle="collapse" href="#comment-func-remainderreportingoverflow-dividingby_">func remainderReportingOverflow(<wbr>dividingBy:)</a>
        
<div class="comment collapse" id="comment-func-remainderreportingoverflow-dividingby_"><div class="p">
    <p>Returns the remainder after dividing this value by the given value, along
with a Boolean value indicating whether overflow occurred during division.</p>

<p>Dividing by zero is not an error when using this method. For a value <code>x</code>,
the result of <code>x.remainderReportingOverflow(dividingBy: 0)</code> is
<code>(x, true)</code>.</p>

<p><strong><code>rhs</code>:</strong>  The value to divide this value by.
<strong>Returns:</strong> A tuple containing the result of the operation along with a
  Boolean value indicating whether overflow occurred. If the <code>overflow</code>
  component is <code>false</code>, the <code>partialValue</code> component contains the entire
  remainder. If the <code>overflow</code> component is <code>true</code>, an overflow occurred
  during division and the <code>partialValue</code> component contains either the
  entire remainder or, if the remainder is undefined, the dividend.</p>

    <h4>Declaration</h4>    
    <code class="language-swift">func remainderReportingOverflow(dividingBy other: Int16) -&gt; (partialValue: Int16, overflow: Bool)</code>
    
    
</div></div>
</div>
<div class="declaration" id="func-signum">
<a class="toggle-link" data-toggle="collapse" href="#comment-func-signum">func signum()</a>
        
<div class="comment collapse" id="comment-func-signum"><div class="p">
    <p>Returns <code>-1</code> if this value is negative and <code>1</code> if it&#39;s positive;
otherwise, <code>0</code>.</p>

<p><strong>Returns:</strong> The sign of this number, expressed as an integer of the same
  type.</p>

    <h4>Declaration</h4>    
    <code class="language-swift">func signum() -&gt; Int16</code>
    
        <h4>Declared In</h4>
        <a href="../../protocol/Int16/"><code>Int16</code></a>,    <a href="../../protocol/FixedWidthInteger/"><code>FixedWidthInteger</code></a>    
</div></div>
</div>
<div class="declaration" id="func-subtractingreportingoverflow_">
<a class="toggle-link" data-toggle="collapse" href="#comment-func-subtractingreportingoverflow_">func subtractingReportingOverflow(<wbr>_:)</a>
        
<div class="comment collapse" id="comment-func-subtractingreportingoverflow_"><div class="p">
    <p>Returns the difference obtained by subtracting the given value from this
value, along with a Boolean value indicating whether overflow occurred in
the operation.</p>

<p><strong><code>rhs</code>:</strong>  The value to subtract from this value.
<strong>Returns:</strong> A tuple containing the result of the subtraction along with a
  Boolean value indicating whether overflow occurred. If the <code>overflow</code>
  component is <code>false</code>, the <code>partialValue</code> component contains the entire
  difference. If the <code>overflow</code> component is <code>true</code>, an overflow occurred
  and the <code>partialValue</code> component contains the truncated result of <code>rhs</code>
  subtracted from this value.</p>

    <h4>Declaration</h4>    
    <code class="language-swift">func subtractingReportingOverflow(_ other: Int16) -&gt; (partialValue: Int16, overflow: Bool)</code>
    
    
</div></div>
</div>
<div class="declaration inherited" id="func-unsafeadding_">
<a class="toggle-link" data-toggle="collapse" href="#comment-func-unsafeadding_">func unsafeAdding(<wbr>_:)</a>
        
<div class="comment collapse" id="comment-func-unsafeadding_"><div class="p">
    <p>Returns the sum of this value and the given value without checking for
arithmetic overflow.</p>

<p>Use this function only to avoid the cost of overflow checking when you
are certain that the operation won&#39;t overflow. In optimized builds (<code>-O</code>)
the compiler is free to assume that overflow won&#39;t occur. Failure to
satisfy that assumption is a serious programming error and could lead to
statements being unexpectedly executed or skipped.</p>

<p>In debug builds (<code>-Onone</code>) a runtime error is still triggered if the
operation overflows.</p>

<p><strong><code>rhs</code>:</strong>  The value to add to this value.
<strong>Returns:</strong> The sum of this value and <code>rhs</code>.</p>

    <h4>Declaration</h4>    
    <code class="language-swift">func unsafeAdding(_ other: Int16) -&gt; Int16</code>
    
        <h4>Declared In</h4>
        <a href="../../protocol/FixedWidthInteger/"><code>FixedWidthInteger</code></a>    
</div></div>
</div>
<div class="declaration inherited" id="func-unsafedivided-by_">
<a class="toggle-link" data-toggle="collapse" href="#comment-func-unsafedivided-by_">func unsafeDivided(<wbr>by:)</a>
        
<div class="comment collapse" id="comment-func-unsafedivided-by_"><div class="p">
    <p>Returns the quotient obtained by dividing this value by the given value
without checking for arithmetic overflow.</p>

<p>Use this function only to avoid the cost of overflow checking when you
are certain that the operation won&#39;t overflow. In optimized builds (<code>-O</code>)
the compiler is free to assume that overflow won&#39;t occur. Failure to
satisfy that assumption is a serious programming error and could lead to
statements being unexpectedly executed or skipped.</p>

<p>In debug builds (<code>-Onone</code>) a runtime error is still triggered if the
operation overflows.</p>

<p><strong><code>rhs</code>:</strong>  The value to divide this value by.
<strong>Returns:</strong> The result of dividing this value by <code>rhs</code>.</p>

    <h4>Declaration</h4>    
    <code class="language-swift">func unsafeDivided(by other: Int16) -&gt; Int16</code>
    
        <h4>Declared In</h4>
        <a href="../../protocol/FixedWidthInteger/"><code>FixedWidthInteger</code></a>    
</div></div>
</div>
<div class="declaration inherited" id="func-unsafemultiplied-by_">
<a class="toggle-link" data-toggle="collapse" href="#comment-func-unsafemultiplied-by_">func unsafeMultiplied(<wbr>by:)</a>
        
<div class="comment collapse" id="comment-func-unsafemultiplied-by_"><div class="p">
    <p>Returns the product of this value and the given value without checking
for arithmetic overflow.</p>

<p>Use this function only to avoid the cost of overflow checking when you
are certain that the operation won&#39;t overflow. In optimized builds (<code>-O</code>)
the compiler is free to assume that overflow won&#39;t occur. Failure to
satisfy that assumption is a serious programming error and could lead to
statements being unexpectedly executed or skipped.</p>

<p>In debug builds (<code>-Onone</code>) a runtime error is still triggered if the
operation overflows.</p>

<p><strong><code>rhs</code>:</strong>  The value to multiply by this value.
<strong>Returns:</strong> The product of this value and <code>rhs</code>.</p>

    <h4>Declaration</h4>    
    <code class="language-swift">func unsafeMultiplied(by other: Int16) -&gt; Int16</code>
    
        <h4>Declared In</h4>
        <a href="../../protocol/FixedWidthInteger/"><code>FixedWidthInteger</code></a>    
</div></div>
</div>
<div class="declaration inherited" id="func-unsafesubtracting_">
<a class="toggle-link" data-toggle="collapse" href="#comment-func-unsafesubtracting_">func unsafeSubtracting(<wbr>_:)</a>
        
<div class="comment collapse" id="comment-func-unsafesubtracting_"><div class="p">
    <p>Returns the difference obtained by subtracting the given value from this
value without checking for arithmetic overflow.</p>

<p>Use this function only to avoid the cost of overflow checking when you
are certain that the operation won&#39;t overflow. In optimized builds (<code>-O</code>)
the compiler is free to assume that overflow won&#39;t occur. Failure to
satisfy that assumption is a serious programming error and could lead to
statements being unexpectedly executed or skipped.</p>

<p>In debug builds (<code>-Onone</code>) a runtime error is still triggered if the
operation overflows.</p>

<p><strong><code>rhs</code>:</strong>  The value to subtract from this value.
<strong>Returns:</strong> The result of subtracting <code>rhs</code> from this value.</p>

    <h4>Declaration</h4>    
    <code class="language-swift">func unsafeSubtracting(_ other: Int16) -&gt; Int16</code>
    
        <h4>Declared In</h4>
        <a href="../../protocol/FixedWidthInteger/"><code>FixedWidthInteger</code></a>    
</div></div>
</div>


<h3>Conditionally Inherited Items</h3>

<p class="comment">The initializers, methods, and properties listed below may be available on this type under certain conditions (such as methods that are available on <code>Array</code> when its elements are <code>Equatable</code>) or may not ever be available if that determination is beyond SwiftDoc.org's capabilities. Please <a href="https://github.com/SwiftDocOrg/swiftdoc.org/issues">open an issue on GitHub</a> if you see something out of place!</p>





<h4>Where Magnitude : UnsignedInteger, Stride : SignedInteger</h4>




<div class="declaration inherited" id="func-magnitude_-unsignedinteger-stride_-signedinteger-random-in_-closedrange-self">
<a class="toggle-link" data-toggle="collapse" href="#comment-func-magnitude_-unsignedinteger-stride_-signedinteger-random-in_-closedrange-self">static func random(<wbr>in: ClosedRange&lt;Int16&gt;)</a>
        
<div class="comment collapse" id="comment-func-magnitude_-unsignedinteger-stride_-signedinteger-random-in_-closedrange-self"><div class="p">
    <p>Returns a random value within the specified range.</p>

<p>Use this method to generate an integer within a specific range. This
example creates three new values in the range <code>1...100</code>.</p>

<pre><code class="language-swift">for _ in 1...3 {
    print(Int.random(in: 1...100))
}
// Prints &quot;53&quot;
// Prints &quot;64&quot;
// Prints &quot;5&quot;</code></pre>

<p>This method uses the default random generator, <code>Random.default</code>. The call
to <code>Int.random(in: 1...100)</code> above is equivalent to calling
<code>Int.random(in: 1...100, using: &amp;Random.default)</code>.</p>

<p><strong><code>range</code>:</strong>  The range in which to create a random value.
<strong>Returns:</strong> A random value within the bounds of <code>range</code>.</p>

    <h4>Declaration</h4>    
    <code class="language-swift">static func random(in range: ClosedRange&lt;Int16&gt;) -&gt; Int16</code>
    
        <h4>Declared In</h4>
        <a href="../../protocol/FixedWidthInteger/"><code>FixedWidthInteger</code></a>    
</div></div>
</div>
<div class="declaration inherited" id="func-magnitude_-unsignedinteger-stride_-signedinteger-random-in_-range-self">
<a class="toggle-link" data-toggle="collapse" href="#comment-func-magnitude_-unsignedinteger-stride_-signedinteger-random-in_-range-self">static func random(<wbr>in: Range&lt;Int16&gt;)</a>
        
<div class="comment collapse" id="comment-func-magnitude_-unsignedinteger-stride_-signedinteger-random-in_-range-self"><div class="p">
    <p>Returns a random value within the specified range.</p>

<p>Use this method to generate an integer within a specific range. This
example creates three new values in the range <code>1..&lt;100</code>.</p>

<pre><code class="language-swift">for _ in 1...3 {
    print(Int.random(in: 1..&lt;100))
}
// Prints &quot;53&quot;
// Prints &quot;64&quot;
// Prints &quot;5&quot;</code></pre>

<p>This method uses the default random generator, <code>Random.default</code>. The call
to <code>Int.random(in: 1..&lt;100)</code> above is equivalent to calling
<code>Int.random(in: 1..&lt;100, using: &amp;Random.default)</code>.</p>

<p><strong><code>range</code>:</strong>  The range in which to create a random value.
  <code>range</code> must not be empty.
<strong>Returns:</strong> A random value within the bounds of <code>range</code>.</p>

    <h4>Declaration</h4>    
    <code class="language-swift">static func random(in range: Range&lt;Int16&gt;) -&gt; Int16</code>
    
        <h4>Declared In</h4>
        <a href="../../protocol/FixedWidthInteger/"><code>FixedWidthInteger</code></a>    
</div></div>
</div>
<div class="declaration inherited" id="func-magnitude_-unsignedinteger-stride_-signedinteger-random-t-in_-closedrange-self-using_-inout-t">
<a class="toggle-link" data-toggle="collapse" href="#comment-func-magnitude_-unsignedinteger-stride_-signedinteger-random-t-in_-closedrange-self-using_-inout-t">static func random&lt;T&gt;(<wbr>in:<wbr> ClosedRange&lt;Int16&gt;, using: inout T)</a>
        
<div class="comment collapse" id="comment-func-magnitude_-unsignedinteger-stride_-signedinteger-random-t-in_-closedrange-self-using_-inout-t"><div class="p">
    <p>Returns a random value within the specified range, using the given
generator as a source for randomness.</p>

<p>Use this method to generate an integer within a specific range when you
are using a custom random number generator. This example creates three
new values in the range <code>1...100</code>.</p>

<pre><code class="language-swift">for _ in 1...3 {
    print(Int.random(in: 1...100, using: &amp;myGenerator))
}
// Prints &quot;7&quot;
// Prints &quot;44&quot;
// Prints &quot;21&quot;</code></pre>

<p><strong>Parameters:</strong>
  <strong>range:</strong> The range in which to create a random value.
  <strong>generator:</strong> The random number generator to use when creating the
    new random value.
<strong>Returns:</strong> A random value within the bounds of <code>range</code>.</p>

    <h4>Declaration</h4>    
    <code class="language-swift">static func random&lt;T&gt;(in range: ClosedRange&lt;Int16&gt;, using generator: inout T) -&gt; Int16 where T : RandomNumberGenerator</code>
    
        <h4>Declared In</h4>
        <a href="../../protocol/FixedWidthInteger/"><code>FixedWidthInteger</code></a>    
</div></div>
</div>
<div class="declaration inherited" id="func-magnitude_-unsignedinteger-stride_-signedinteger-random-t-in_-range-self-using_-inout-t">
<a class="toggle-link" data-toggle="collapse" href="#comment-func-magnitude_-unsignedinteger-stride_-signedinteger-random-t-in_-range-self-using_-inout-t">static func random&lt;T&gt;(<wbr>in:<wbr> Range&lt;Int16&gt;, using: inout T)</a>
        
<div class="comment collapse" id="comment-func-magnitude_-unsignedinteger-stride_-signedinteger-random-t-in_-range-self-using_-inout-t"><div class="p">
    <p>Returns a random value within the specified range, using the given
generator as a source for randomness.</p>

<p>Use this method to generate an integer within a specific range when you
are using a custom random number generator. This example creates three
new values in the range <code>1..&lt;100</code>.</p>

<pre><code class="language-swift">for _ in 1...3 {
    print(Int.random(in: 1..&lt;100, using: &amp;myGenerator))
}
// Prints &quot;7&quot;
// Prints &quot;44&quot;
// Prints &quot;21&quot;</code></pre>

<p><strong>Parameters:</strong>
  <strong>range:</strong> The range in which to create a random value.
    <code>range</code> must not be empty.
  <strong>generator:</strong> The random number generator to use when creating the
    new random value.
<strong>Returns:</strong> A random value within the bounds of <code>range</code>.</p>

    <h4>Declaration</h4>    
    <code class="language-swift">static func random&lt;T&gt;(in range: Range&lt;Int16&gt;, using generator: inout T) -&gt; Int16 where T : RandomNumberGenerator</code>
    
        <h4>Declared In</h4>
        <a href="../../protocol/FixedWidthInteger/"><code>FixedWidthInteger</code></a>    
</div></div>
</div>





<h4>Where Stride : SignedInteger</h4>




<div class="declaration inherited" id="func-stride_-signedinteger-dotdotdot_maximum_">
<a class="toggle-link" data-toggle="collapse" href="#comment-func-stride_-signedinteger-dotdotdot_maximum_">func ...(<wbr>_:<wbr>maximum:)</a>
        
<div class="comment collapse" id="comment-func-stride_-signedinteger-dotdotdot_maximum_"><div class="p">
    <p>Returns a countable closed range that contains both of its bounds.</p>

<p>Use the closed range operator (<code>...</code>) to create a closed range of any type
that conforms to the <code>Strideable</code> protocol with an associated signed
integer <code>Stride</code> type, such as any of the standard library&#39;s integer
types. This example creates a <code>ClosedRange&lt;Int&gt;</code> from zero up to,
and including, nine.</p>

<pre><code class="language-swift">let singleDigits = 0...9
print(singleDigits.contains(9))
// Prints &quot;true&quot;</code></pre>

<p>You can use sequence or collection methods on the <code>singleDigits</code> range.</p>

<pre><code class="language-swift">print(singleDigits.count)
// Prints &quot;10&quot;
print(singleDigits.last)
// Prints &quot;9&quot;</code></pre>

<p><strong>Parameters:</strong>)`.
  <strong>minimum:</strong> The lower bound for the range.
  <strong>maximum:</strong> The upper bound for the range.</p>

    <h4>Declaration</h4>    
    <code class="language-swift">func ...(minimum: Int16, maximum: Int16) -&gt; ClosedRange&lt;Int16&gt;</code>
    
        <h4>Declared In</h4>
        <a href="../../protocol/FixedWidthInteger/"><code>FixedWidthInteger</code></a>    
</div></div>
</div>



